/*
 *  CELabelMBFontWrapperScissored.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_LabelMBFontWrapperScissored_h__
#define __CE_LabelMBFontWrapperScissored_h__

#include "cocos2dx_extentions/nodes/CENodeRGBA.h"
#include "cocos2dx_extentions/labels/CELabelProtocol.h"
#include "cocos2dx_extentions/nodes/CENodeScissored.h"
#include "cocos2dx_extentions/labels/CELabelBMFont.h"

namespace cocosext {

#define CE_LIST_EDIT_CURSOR_HALF_TIME 0.5f

typedef enum
{
	eCE_TA_left = 0,
	eCE_TA_center,
	eCE_TA_right,
	eCE_TA_left_to_right,
} ECETextAllign;

/////////////////////////////////////////////////////
//
/** CELabelMBFontWrapperScissored 
* 
*/
////////////////////////////////////////////////////

class CELabelMBFontWrapperScissored : public CENodeRGBA, public CELabelProtocol
{
protected:
	//Frame and scrollable area
	CELabelBMFont* _label;
	CENodeScissored<cocos2d::CCNode>* _frame;
	ECETextAllign _ta;

protected:
	CELabelMBFontWrapperScissored(CELabelBMFont* label, ECETextAllign ta)
		: _label(label), _frame(NULL), _ta(ta) {;}
	
	virtual bool init();

public:
    virtual ~CELabelMBFontWrapperScissored() {;}

	static CELabelMBFontWrapperScissored* node(CELabelBMFont* label, ECETextAllign ta = eCE_TA_left);

public:
// CELabelProtocol interface
	virtual void setString(const wchar_t *str);
	virtual const wchar_t* getString(void) const { return _label->getString(); }

// Cocos2d interface
	virtual void setRotation(float fRotation);
	virtual void setContentSize(const cocos2d::CCSize& contentSize);

protected:
	virtual void updateLeftToRightAllign();
	virtual void updateLabelPosition();
}; //class CELabelMBFontWrapperScissored


/////////////////////////////////////////////////////
//
/** CELabelMBFontWrapScis_cursor 
* 
*/
////////////////////////////////////////////////////

class CELabelMBFontWrapScis_cursor : public CELabelMBFontWrapperScissored
{
protected:
	//Frame and scrollable area
	cocos2d::CCNode* _cursor;

protected:
	CELabelMBFontWrapScis_cursor(CELabelBMFont* label, cocos2d::CCNode* cursor, ECETextAllign ta)
		: CELabelMBFontWrapperScissored(label, ta)
		, _cursor(cursor) {;}
	
	virtual bool init();

public:
    virtual ~CELabelMBFontWrapScis_cursor() {;}

	static CELabelMBFontWrapScis_cursor* node(CELabelBMFont* label, cocos2d::CCNode* cursor, ECETextAllign ta = eCE_TA_left);

public:
// CELabelProtocol interface
void setString(const wchar_t *str);

protected:
	virtual void updateLeftToRightAllign();
	virtual void updateLabelPosition();
}; //class CELabelMBFontWrapperScissored	

}; // end namespace cocosext

#endif // __CE_LabelMBFontWrapperScissored_h__
